package contracts.topic

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'POST'
        url value('/api/diff/topics')
        headers {
            header('Content-Type', 'application/json;charset=UTF-8')
        }
        body("""
                 {
                    "topicId":1,
                    "programId":1,
                    "title":"title",
                    "type":"update",
                    "visible":true,
                    "operatorId":1,
                    "operation":"UPDATE",
                 } 
                """
        )
        bodyMatchers {
            jsonPath('$.title', byRegex("[\\s\\S]*"))
            jsonPath('$.type', byRegex("[\\s\\S]*"))
            jsonPath('$.operation', byRegex("[\\s\\S]+"))
            jsonPath('$.visible', byRegex(nonEmpty()))
            jsonPath('$.topicId', byRegex(number()))
            jsonPath('$.operatorId', byRegex(number()))
            jsonPath('$.programId', byRegex(number()))
        }
    }
    response {
        status 201
    }
}
